import tableComponent from "../package/table-component";
import toolTip from "../package/tool-tip";
import draggableResizable from "../package/draggable-resizable";
import queryCondition from "../package/query-condition";
import loadingView from "@/package/loading-view";

const components = [
  tableComponent,
  toolTip,
  draggableResizable,
  queryCondition,
  loadingView
];
// 定义 install 方法，接收 Vue 作为参数。如果使用 use 注册插件，则所有的组件都将被注册
const install = function (Vue) {
  // 判断是否安装
  if (install.installed) return;
  // 遍历注册全局组件
  components.forEach(component => Vue.component(component.name, component));
};

// 判断是否直接引入文件，如果是，就不用调用Vue.use()
if (typeof window !== 'undefined' && window.Vue) {
  window.Vue.use(window.Vue);
}

//导出
export default {
  install,
  // 以下是具体的组件列表
  tableComponent,
  toolTip,
  draggableResizable,
  queryCondition,
  loadingView
};
